{include file="../app/index/view/public.header.html" /}
<form class="layui-form layui-form-pane" style="padding: 16px">
    <div class="layui-form-item">
        <label class="layui-form-label" for="mobile">手机号码</label>
        <div class="layui-input-block">
            <input class="layui-input" name="mobile" id="mobile" type="text" placeholder="请输入手机号" value="{$data.member_mobile}" autocomplete="off" lay-verify="required"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" for="name">用户姓名</label>
        <div class="layui-input-block">
            <input class="layui-input" name="name" id="name" type="text" placeholder="请输入用户姓名" value="{$data.member_name}" autocomplete="off" lay-verify="required"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" for="age">用户年龄</label>
        <div class="layui-input-block">
            <input class="layui-input" name="age" id="age" type="text" placeholder="请输入用户年龄" value="{$data.member_age}" autocomplete="off" lay-verify="required"/>
        </div>
    </div>

    <div class="layui-upload">
        <label class="layui-form-label" for="test1">用户头像</label>
        <button type="button" class="layui-btn" id="test1">上传图片</button>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">图片预览</label>
        <div class="layui-upload-list">
            <img class="layui-upload-img" id="demo1" src="http://127.0.0.1/upload/{$data.member_avatar}" style="width: 160px;height: 160px">
            <p id="demoText"></p>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" type="submit" lay-filter="submit" lay-submit="">提交</button>
            <button class="layui-btn" type="reset">重置</button>
        </div>
    </div>
</form>
<script type="text/javascript">
    layui.use(["layer", "form", "table", "upload", "element", "laydate"], function () {

        let fileName = '';

        let uploadInst = layui.upload.render({
            elem: '#test1'
            , url: 'http://127.0.0.1/index.php/index/member/upload/' //改成您自己的上传接口
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    layui.jquery('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                fileName = res.data;
            }
            , error: function (res) {
                showMessage('上传失败');
            }
        });

        layui.form.on('submit(submit)', function (data) {
            postNormal(location.href, {
                    mobile: data.field.mobile,
                    name: data.field.name,
                    age: data.field.age,
                    filename: fileName,
                },
                function (result) {
                    closeAll();
                    if (result.code !== '1') {
                        showMessage(result.msg);
                        return;
                    }
                    showMessage("修改成功~");
                })
            return false;
        });
    });
</script>
{include file="../app/index/view/public.footer.html" /}
